package server.logger;

import java.util.HashMap;

public class Logger {
    private String name;
    //打日志
    public void log(String message) {
        System.out.println(name + " " + message);
    }
    public void log(String message, Throwable throwable) {
        System.out.println(name + " " + message);
        throwable.printStackTrace(System.out);
    }

    private Logger(String name) {
        this.name = name;
    }

    private static HashMap<String, Logger> loggers = new HashMap<>();
    public static Logger getLogger(String name) {
        Logger logger = loggers.get(name);
        if (logger == null) {
            logger = new Logger(name);
            loggers.put(name, logger);
        }
        return logger;
    }
}
